#ifndef PRESETSERVER_H
#define PRESETSERVER_H

#include <QMap>
#include <QVariant>
#include "presetobject.h"

class PresetServer
{
public:
    PresetServer(const QString &path);
    virtual ~PresetServer();

    void initialize();

    void setData(int itemName, const QVariant &value);

    bool getBoolData(int itemName);
    bool getBoolData(const QString &key);

    int getIntData(int itemName);
    int getIntData(const QString &key);

    double getDoubleData(int itemName);
    double getDoubleData(const QString &key);

    QString getStringData(int itemName);
    QString getStringData(const QString &key);

    int getIntDefault(int itemName);
    double getDoubleDefault(int itemName);
    QString getStringDefault(int itemName);

    QStringList getKeyList();
    void restoreDefault(int itemName);

protected:
    void registerItem(int itemName, const QString &keyName, const QString &defaultValue);

private:
    void fillMissItems();
    void restoreDefault();
    void read(PresetObject &presetObject);
    void save(const PresetObject &presetObject);

private:
    QMap<int, PresetObject> m_itemList;
    QMap<QString, int>   m_keyItemList;
    QString m_filePath;
};
#endif // PRESETSERVER_H
